package conson.tech.manage.coupons.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import conson.tech.manage.coupons.entity.dto.CouponDto;
import conson.tech.manage.coupons.entity.dto.CouponsGrantDto;
import conson.tech.manage.coupons.entity.dto.UserCouponListDto;
import conson.tech.manage.coupons.entity.pojo.CouponsUsers;
import conson.tech.manage.coupons.entity.vo.CouponsGrantVo;
import conson.tech.manage.coupons.entity.vo.UserCouponDetailVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 * InterfaceName: CouponsUsersMapper
 * Description:
 * Author: ZYF
 * Date: 2020/7/20
 * Version: 1.0
 */
public interface CouponsUsersMapper extends BaseMapper<CouponsUsers> {

    /**
     * 查询发放优惠券列表
     *
     * @param page
     * @param dto  入参
     */
    Page<CouponsGrantVo> queryList(Page<CouponsGrantVo> page, @Param("dto") CouponsGrantDto dto);

    /**
     * 根据优惠券券码查询优惠券信息
     */
    CouponsUsers selectCouponsUser(@Param("couponsCode") String couponsCode);


    /**
     * 按活动id获取关联的优惠券列表
     *
     * @param page
     * @param id
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<conson.tech.manage.app.entity.vo.ActivityCouponPageVo>
     */
    Page<UserCouponDetailVo> couponActivityList(Page<UserCouponDetailVo> page, @Param("id") Long id);

    /**
     * 获取用户我的优惠券列表
     *
     * @param currentUserId
     * @param page
     * @param dto
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<conson.tech.manage.app.entity.vo.ActivityCouponPageVo>
     */
    Page<UserCouponDetailVo> userCouponList(@Param("currentUserId") Long currentUserId, Page<UserCouponDetailVo> page, @Param("dto") UserCouponListDto dto);


    /**
     * 获取用户优惠券配置信息
     *
     * @param currentUserId
     * @param dto
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<conson.tech.manage.app.entity.vo.ActivityCouponPageVo>
     */
    List<UserCouponDetailVo> couponConfigDetails(@Param("currentUserId") Long currentUserId, @Param("dto") CouponDto dto);


    /**
     * 获取用户已经领取的券的数量
     *
     * @param userId  用户id
     * @param batchId 优惠券批次id
     * @param batchId 活动配置id
     */
    int queryUserName(@Param("userId") Long userId, @Param("batchId") Long batchId, @Param("id") Long id);

}
